Switch Node

Overview

The Switch node is a generalization of the Condition Node to at least 2 cases used to execute one of many sub-flowcharts based on expressions for each case.

Upon placing a Switch node, generates two sub-flowcharts, ‘Case 1’ and ‘Default’.

Each case has an input ‘Condition: case_x’ which when evaluates to true, causes that case’s sub-flowchart to be executed when the switch node is hit. If multiple cases have conditions evaluate to True, then the smallest number case’s sub-flowchart will be executed (i.e. if Case 1 and Case 2 both have input conditions that evaluate to True, only Case 1’s sub-flowchart would be executed). The Default case’s sub-flowchart will execute when all other cases are evaluated to false.

../../_images/switch_overview_1.png ../../_images/switch_overview_2.png

Below is an example of using the Switch node to switch between different calibration types.

../../_images/switch_node.png ../../_images/switch_node_exp.png

Output

Output

Type

Description

Condition

bool

The boolean value of the input Condition expression.

Procedure to Use

  1. Set up the flowchart as in the following image.

../../_images/switch_procedure_1.png

  1. Click the Constant node. Change the Int Field to 2.

../../_images/switch_procedure_2.png

  1. Click the Switch node, select case_2 and Advanced mode. Let condition: case_2 evaluates to True when the Constant Int is 2.

../../_images/switch_procedure_3.png

  1. Click the Print node. Type a print message.

../../_images/switch_procedure_4.png

  1. Click the Halt node. Set the Halt value to True.

../../_images/switch_procedure_5.png

  1. Run the flowchart. You can see the print message from Case 2, and the flowchart is halted.

../../_images/switch_procedure_6.png

Exercise

  1. Given there are case_1, case_2, case_3, and case_default. If both case_2 and case_3 are true, which case is run?

  1. case_1

  2. case_2

  3. case_3

  4. case_default
















Answers for Exercise

    1. case_2 is run. When two cases evaluate to True, the sub-flowchart of the case with smaller number is run.